public class Main {
    static class MyThread extends Thread {
        @Override
        public void run() {
            while (true) {
                System.out.println("MyThread");
                try {
                    Thread.sleep(1000);
                } catch ( InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }

    }
    public static void main(String[] args) throws InterruptedException {

        Thread thread = new MyThread();
        thread.start();
        while (true) {
            System.out.println("main");
            Thread.sleep(1000);
        }

    }
}
